<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
        <script src="./echarts.min.js"></script>
    </head>
    <body>
        <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
        <div id="main" style="width: 600px; height: 400px"></div>
        <script>
            // 基于准备好的dom，初始化echarts实例
            const myChart = echarts.init(document.querySelector("#main"));

            const option = {
                title: [
                    {
                        text: "男女薪资分布",
                    },
                    {
                        subtext: "男生",
                        left: "center",
                        top: "40%",
                    },
                    {
                        subtext: "女生",
                        left: "center",
                        top: "90%",
                    },
                ],
                tooltip: {
                    trigger: "item",
                },
                series: [
                    {
                        name: "男生",
                        type: "pie",
                        radius: ["40%", "60%"],
                        data: [
                            {
                                name: "1万以下",
                                value: 3,
                            },
                            {
                                name: "1-1.5万",
                                value: 12,
                            },
                            {
                                name: "1.5-2万",
                                value: 8,
                            },
                            {
                                name: "2万以上",
                                value: 13,
                            },
                        ],
                        label: {
                            position: "outer",
                            alignTo: "none",
                            bleedMargin: 5,
                        },
                        left: "center",
                        bottom: "50%",
                    },
                    {
                        name: "女生",
                        type: "pie",
                        radius: ["40%", "60%"],
                        data: [
                            {
                                name: "1万以下",
                                value: 1,
                            },
                            {
                                name: "1-1.5万",
                                value: 13,
                            },
                            {
                                name: "1.5-2万",
                                value: 14,
                            },
                            {
                                name: "2万以上",
                                value: 10,
                            },
                        ],
                        label: {
                            position: "outer",
                            alignTo: "labelLine",
                            bleedMargin: 5,
                        },
                        left: "center",
                        top: "50%",
                    },
                ],
                color: ["#fda224", "#5097ff", "#3fceff", "#34d39a"],
            };

            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
        </script>
    </body>
</html>
